// Copyright Epic Games, Inc. All Rights Reserved.

#include "LyraCosmeticAnimationTypes.h"

#include "Animation/AnimInstance.h"
#include "Engine/SkeletalMesh.h"

#include UE_INLINE_GENERATED_CPP_BY_NAME(LyraCosmeticAnimationTypes)

/**
 * 根据化妆标签选择最佳动画层
 */
TSubclassOf<UAnimInstance> FLyraAnimLayerSelectionSet::SelectBestLayer(const FGameplayTagContainer& CosmeticTags) const
{
	for (const FLyraAnimLayerSelectionEntry& Rule : LayerRules) // 遍历层规则
	{
		if ((Rule.Layer != nullptr) && CosmeticTags.HasAll(Rule.RequiredTags)) // 如果层有效且标签完全匹配
		{
			return Rule.Layer; // 返回匹配的层
		}
	}

	return DefaultLayer; // 返回默认层
}

/**
 * 根据化妆标签选择最佳身体风格网格体
 */
USkeletalMesh* FLyraAnimBodyStyleSelectionSet::SelectBestBodyStyle(const FGameplayTagContainer& CosmeticTags) const
{
	for (const FLyraAnimBodyStyleSelectionEntry& Rule : MeshRules) // 遍历网格体规则
	{
		if ((Rule.Mesh != nullptr) && CosmeticTags.HasAll(Rule.RequiredTags)) // 如果网格体有效且标签完全匹配
		{
			return Rule.Mesh; // 返回匹配的网格体
		}
	}

	return DefaultMesh; // 返回默认网格体
}